
var monitor = {};
monitor.LOCK_ACTIVITY = "LOCK_ACTIVITY";
monitor.UN_LOCK_ACTIVITY = "UN_LOCK_ACTIVITY";
monitor.lockActivity = function(activity){
    events.broadcast.emit(this.LOCK_ACTIVITY, activity);
}
monitor.unLockActivity = function(){
    events.broadcast.emit(this.UN_LOCK_ACTIVITY);
}
monitor.alert = function(){
    var w = floaty.rawWindow(
        <frame id="frame" gravity="center" bg="#ffff0000">
          <text id="example" text="" gravity="center" textSize="50sp" />
        </frame>
      );
      media.playMusic(files.cwd() + "/gdt_hb/music/科技.mp3")
      w.setSize(-1, -1);
      // w.setTouchable(false);
      
      // setTimeout(()=>{
      //   w.close();
      // }, 60000);
      var f = true;
      var t = threads.start(function(){
        sleep(3000);
        media.playMusic(files.cwd() + "/gdt_hb/music/警报.mp3", 1, true)
        while(true){
          if (f) {
            w.frame.attr("bg", "#00ff0000");
          } else {
            w.frame.attr("bg", "#ffff0000");
          }
          f = !f;
          sleep(500);
        }
      })
      // setTimeout(function(){
      //   clearInterval(id);
      // }, 5000);
      w.frame.on("click", function(){
        media.stopMusic();
        media.playMusic(files.cwd() + "/gdt_hb/music/科技.mp3");
        t.interrupt();
      });
      
    
}


module.exports = monitor;